package javagprssrv.Task;

import javagprssrv.JGS_Param;
import javagprssrv.StructClass.structTask;
import javagprssrv.DataAnalyse.ScriptExecuter;

public class Old_TrdTasksVectorCreater extends java.lang.Thread
{
    private javagprssrv.DataAnalyse.ScriptExecuter SE;
    
    public Old_TrdTasksVectorCreater() {
        this.SE = null;
    }
    
    @java.lang.Override
    public void run() {
        while (true) {
            javagprssrv.StructClass.structTask Task = new javagprssrv.StructClass.structTask();
            boolean isFind = false;
            synchronized (javagprssrv.JGS_Param.TempTasks) {
                if (javagprssrv.JGS_Param.TempTasks.size() > 0) {
                    isFind = true;
                    Task = javagprssrv.JGS_Param.TempTasks.remove(0);
                }
            }
            if (!isFind) {
                try {
                    java.lang.Thread.sleep(50L);
                }
                catch (java.lang.Exception ex) {}
                Task = null;
            }
            else {
                if (!Task.Term_SerialNo.trim().equals("")) {
                    if (!Task.Task_Job.trim().equals("")) {
                        isFind = false;
                        int idxTasks = -1;
                        synchronized (javagprssrv.JGS_Param.Tasks) {
                            for (int i = 0; i < javagprssrv.JGS_Param.Tasks.size(); ++i) {
                                if (javagprssrv.JGS_Param.Tasks.elementAt(i).Term_SerialNo.equals(Task.Term_SerialNo)) {
                                    isFind = true;
                                    idxTasks = i;
                                    break;
                                }
                            }
                            if (isFind) {
                                boolean isFindSameJob = false;
                                if (javagprssrv.JGS_Param._CanAddSameJob == 0) {
                                    for (int idxOriginJobs = 0; idxOriginJobs < javagprssrv.JGS_Param.Tasks.elementAt(idxTasks).Task_OriginJobs.size(); ++idxOriginJobs) {
                                        if (javagprssrv.JGS_Param.Tasks.elementAt(idxTasks).Task_OriginJobs.elementAt(idxOriginJobs).equals(Task.Task_Job)) {
                                            isFindSameJob = true;
                                            break;
                                        }
                                    }
                                }
                                if (!isFindSameJob) {
                                    final java.lang.String Task_Job = this.Convert_Origin2Job(Task.Task_Job);
                                    if (Task_Job.trim().length() > 0) {
                                        javagprssrv.JGS_Param.Tasks.elementAt(idxTasks).Task_Jobs.add(Task_Job);
                                    }
                                }
                            }
                            else {
                                final java.lang.String Task_Job2 = this.Convert_Origin2Job(Task.Task_Job);
                                if (Task_Job2.trim().length() > 0) {
                                    Task.Task_Jobs.add(Task_Job2);
                                    javagprssrv.JGS_Param.Tasks.add(Task);
                                }
                            }
                        }
                        Task = null;
                        continue;
                    }
                }
                try {
                    java.lang.Thread.sleep(50L);
                }
                catch (java.lang.Exception ex2) {}
                Task = null;
            }
        }
    }
    
    private java.lang.String Convert_Origin2Job(final java.lang.String OriginString) {
        final java.lang.String strJob = "";
        return OriginString;
    }
}
